<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006-2016 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 流年 <liu21st@gmail.com>
// +----------------------------------------------------------------------

// 应用公共文件

/**
 * @param $type                 数据类型
 * @param string $msg           返回信息
 * @param array $data           返回数据
 * @return false|string
 */
function successSend($type,$msg = '',array $data = []){
    return json_encode(['type'=>$type,'code'=>true,'msg'=>$msg,'data'=>$data]);
}

/**
 * @param $type                 数据类型
 * @param string $msg           返回信息
 * @param string $code          返回状态
 * @param array $dataa          返回数据
 * @return false|string
 */
function errorSend($type,$code,$msg = '',array $data = []){

    return json_encode(['type'=>$type,'code'=>$code,'msg'=>$msg,'data'=>$data]);
}

function toArray($obj){
    return json_decode(json_encode($obj),true);
}